 
var app = getApp()
Page({
  data: {
    selected: true,
    selected1: false,
    viewshow:false
  },
  selected: function (e) {
    this.setData({
      selected1: false,
      selected: true
    })
  },
  selected1: function (e) {
    this.setData({
      selected: false,
      selected1: true
    })
  },
  viewshow: function (e) {
    this.setData({
      viewshow: true
    })
  },
  viewhide: function (e) {
    this.setData({
      viewshow: false
    })
  },
   toDown: function () {
    wx.navigateTo({
      url: '../downyilin/downyilin',
    })
  },
  toBlackBook: function () {
    if (app.globalData.myId == null || app.globalData.myId == undefined || app.globalData.myId == '') {
      var a = getCurrentPages()[0].route;
      console.log(a)
      wx.navigateTo({
        url: '../../../login/login?a='+a,
      })
    } else {
      wx.navigateTo({
        url: '../blackBook/blackBook',
      })
    }
   
  },
  toBlackBookList: function () {
    wx.navigateTo({
      url: '../blackBookList/blackBookList',
    })
  },
  toYiLiList: function () {
    wx.navigateTo({
      url: '../yilinList/yilinList',
    })
  },
  q: function () {
    wx.navigateBack({ changed: true })
  },
  qq: function () {
    wx.switchTab({

      url: '/pages/index/index',

    });
  },
  saveImage:function() {
    wx.downloadFile({
      url:'http://xiaochengxu-ajihua.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/lianxiewm.png',
      success: function (res) {
        if (res.statusCode === 200) {
          let img = res.tempFilePath;
          console.log(img)
          wx.saveImageToPhotosAlbum({
            filePath: img,
            success(res) {
              wx.showToast({
                title: '保存成功',
                icon: 'success',
                duration: 2000
              });
              this.setData({
                viewshow: false
              })
            },
            fail(res) {
              wx.showToast({
                title: '保存失败',
                icon: 'success',
                duration: 2000
              });
            }
          });
        }
      }
    });
  },

  onReady: function () {
    const vm = this
    vm.setData({
      statusBarHeight: getApp().globalData.statusBarHeight,
      titleBarHeight: getApp().globalData.titleBarHeight
    })

  },
})
